﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExcelTools.Core.NPOI.Extensions
{
    public static class ObjectExtensions
    {
        public static int? TryConvertInt32(this string value)
        {
            Int32 result = 0;
            Int32.TryParse(value, out result);
            return result;
        }
        public static long TryConvertLong(this string value)
        {
            long result = 0;
            long.TryParse(value, out result);
            return result;
        }

        public static Double TryConvertDouble(this string value)
        {
            Double result = 0;
            Double.TryParse(value, out result);
            return result;
        }

        public static DateTime TryConvertDateTime(this string value)
        {
            DateTime result = default(DateTime);
            DateTime.TryParse(value, out result);
            return result;
        }
    }
}
